﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExtAspNet;
using FJASPX.Framwork.Config;
using FJASPX.Framwork.UI;
using FJASPX.Service;
using FJASPX.Framwork.Helper;
using FJASPX.Framwork.Constant;

namespace PlugNT.Cms.Web.Personal
{
    public partial class Default : EditPageBase<FJASPX.Domain.User>
    {
        public IUserService iUserService { get; set; }

        #region Property属性
        public override string PowerCode
        {
            get { throw new NotImplementedException(); }
        }
        #endregion

        #region Methods方法

        protected override bool FirstCallRead()
        {
            //初始化控件
            base.FirstCallRead();
            this.btn_Info.Text = this.CurrentUser.UserName;

            this.Model = iUserService.GetUserByName(this.CurrentUser.UserName);
            if (!this.Model.IsNull())
            {
                this.txt_Infos.SetValue(this.Model.CompanyInfo);
            }
            return true;
        }
        #endregion

        #region Events事件
        protected void btn_Reload_Click(object sender, EventArgs e)
        {

        }
        protected void tir_Main_Tick(object sender, EventArgs e)
        {

        }

        protected void btn_EndLogin_Click(object sender, EventArgs e)
        {
            ExtAspNet.PageContext.Redirect("/LoginOut.aspx");
        }

        protected void btn_My_Click(object sender, EventArgs e)
        {
            if (!Roles.IsUserInRole(ConfigBase.GetConfig(Strings.KEY_ROLE_MEMBER)))
            {
                Alert.Show(Strings.MESSAGE1, Strings.ALERT);
                return;
            }
            Page.Response.RedirectLocation = "/Member/Default.aspx";
        } 

        protected void btn_Update_Click(object sender, EventArgs e)
        {
            this.Model = iUserService.GetUserByName(this.CurrentUser.UserName);
            if (!this.Model.IsNull())
            {
                this.Model.CompanyInfo = this.txt_Infos.GetValue();
                iUserService.Update(this.Model);
            }
        }
        protected void btn_ChangePassword_Click(object sender, EventArgs e)
        {
          PageContext.RegisterStartupScript(win_ChangePassword.GetShowReference());
        }
        #endregion

    

    }
}